package com.kfm.base.thread.day01;

public class Demo04 {

    public static void main(String[] args) {
        Runnable runnable = () -> {
            for (int i = 0; i < 10; i++) {
                String name = Thread.currentThread().getName();
                System.out.println(name + "-runnable : " + i);
            }
        };
        MyThreadA myThreadA = new MyThreadA(runnable);

        myThreadA.start();// 启动线程，会执行 run 方法
    }
}


class MyThreadA extends Thread {

    public MyThreadA(){}

    public MyThreadA(Runnable runnable){
        super(runnable);
    }

    @Override
    public void run(){
        for (int i = 0; i < 10; i++) {
            System.out.println(this.getName() + " : " + i);
        }
    }

}